package com.xucy.springboot.designmodel.behavioral.strategy;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author xucy
 * @Date 2019-07-28 10:39
 * @Description 策略工厂
 **/

public class PromotionFactory {

    public static Map<String,Promotion> promotionMap=new HashMap<>();
    public final static Promotion NO_PROMOTION=new NoPromotion();
    static {
        promotionMap.put("FANXIAN",new FxPromotion());
        promotionMap.put("LIJIAN",new LjPromotion());
    }

    private PromotionFactory(){

    }

    public static Promotion getPromotion(String key){
        Promotion promotion=promotionMap.get(key);

        return  promotion==null?NO_PROMOTION:promotion;
    }

    public interface PromotionKey{
        final String FANXIAN="FANXIAN";
        final String LIJIAN="LIJIAN";
    }
}
